﻿using Com.JunCaiSoft.AddressManage.Entity;
using Com.JunCaiSoft.AddressManage.EntityMap;
using Com.JunCaiSoft.ConstructionCashFlow.Entity;
using Com.JunCaiSoft.ConstructionCashFlow.EntityMap;
using Com.JunCaiSoft.Freeze.EntityMap;
using Com.JunCaiSoft.Hr.EntityMap;
using Com.JunCaiSoft.Law.EntityMap;
using Com.JunCaiSoft.NoticeSystem.EntityMap;
using Com.JunCaiSoft.Permission.Entity;
using Com.JunCaiSoft.Permission.EntityMap;
using Com.JunCaiSoft.SystemConfig.EntityMap;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Com.JunCaiSoft.DBContext
{
    public class MSSQLDbContext : DbContext, IDisposable
    {
        public MSSQLDbContext(DbContextOptions<MSSQLDbContext> options) : base(options)
        {
            Database.EnsureCreated();
        }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.ApplyConfiguration(new AuthorizeMap());
            builder.ApplyConfiguration(new UserMap());
            builder.ApplyConfiguration(new RoleMap());
            builder.ApplyConfiguration(new PositionMap());
            builder.ApplyConfiguration(new BankMap());
            builder.ApplyConfiguration(new BankSettlementMap());
            builder.ApplyConfiguration(new ProjectMap());
            builder.ApplyConfiguration(new ProjectSettlementMap());
            builder.ApplyConfiguration(new CashFlowMap());
            builder.ApplyConfiguration(new FreezeMoneyMap());
            builder.ApplyConfiguration(new CreditContractMap());
            builder.ApplyConfiguration(new UnFreezeMoneyMap());
            builder.ApplyConfiguration(new AdministrativeMap());
            builder.ApplyConfiguration(new BankAccountTypeMap());
            builder.ApplyConfiguration(new ProjectTypeMap());
            builder.ApplyConfiguration(new FundsTypeMap());
            builder.ApplyConfiguration(new CompanyMap());
            builder.ApplyConfiguration(new PartmentMap());
            builder.ApplyConfiguration(new CaseMainMap());
            builder.ApplyConfiguration(new PreservationMap());
            builder.ApplyConfiguration(new CaseHandleMap());
            builder.ApplyConfiguration(new ExcuteCaseMap());
            builder.ApplyConfiguration(new UnFreezingApplicationMap());
            builder.ApplyConfiguration(new CaseTypeMap());
            builder.ApplyConfiguration(new CaseStatusMap());
            builder.ApplyConfiguration(new AppSecretManageMap());
            builder.ApplyConfiguration(new NoticeMap());

            base.OnModelCreating(builder);
        }
    }
}
